package m.jclecai.com.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import m.jclecai.com.R;
import m.jclecai.com.adapter.AllRedPkgAdapter;
import m.jclecai.com.base.BaseActivity;
import m.jclecai.com.base.BaseFragment;
import m.jclecai.com.fragment.message.NoticeFragment;

public class CenterMessageActivity extends BaseActivity {


    List<BaseFragment> pages;
    AllRedPkgAdapter adapter;
    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    String[] title = new String[]{"系统消息", "官方公告", "个人消息"};


    @Override
    protected int getContentView() {
        return R.layout.activity_center_message;
    }


    @Override
    protected void initView() {
        super.initView();
        leftOptionText("");
        setTitle("消息中心");
    }

    @Override
    protected void resetWindow() {

    }

    @Override
    protected void initData() {
        super.initData();
        pages = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            NoticeFragment redPkgFragment = new NoticeFragment();
            redPkgFragment.setType(i);
            pages.add(redPkgFragment);
        }

        adapter = new AllRedPkgAdapter(getSupportFragmentManager(), pages, title);
        viewPager.setAdapter(adapter);
        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout) {
            @Override
            public void onPageScrollStateChanged(int state) {
                super.onPageScrollStateChanged(state);
            }

            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                super.onPageScrolled(position, positionOffset, positionOffsetPixels);
            }

            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
            }
        });
        tabLayout.setupWithViewPager(viewPager);
    }

}
